#include "castle.h"

CCastle::CCastle() : CObjects()
{

}

CCastle::~CCastle()
{

}

CCastle::CCastle(float X, float Y)
{
	reality = 0;
	pos_x = X;
	pos_y = Y;
}

void CCastle::RenderPieceCastle(int P,float x,float y)
{
	if(P == 1)
		StaticPic->Render(_BackBuffer,x,y,4,0);
	else if(P == 2)
		StaticPic->Render(_BackBuffer,x,y,4,2);
	else if(P == 3)
		StaticPic->Render(_BackBuffer,x,y,5,0);
	else if(P == 4)
		StaticPic->Render(_BackBuffer,x,y,5,1);
	else if(P == 5)
		StaticPic->Render(_BackBuffer,x,y,5,2);
	else if(P == 6)
		StaticPic->Render(_BackBuffer,x,y,6,1);
	else
		StaticPic->Render(_BackBuffer,x,y,6,2);
}

void CCastle::RenderFrame(LPDIRECT3DDEVICE9 d3ddv, int t)
{
	SpriteHandlerSP->Begin(D3DXSPRITE_ALPHABLEND);

	RenderPieceCastle(2,pos_x,			pos_y);
	RenderPieceCastle(2,pos_x+DIS,		pos_y);
	RenderPieceCastle(2,pos_x+3*DIS,	pos_y);
	RenderPieceCastle(2,pos_x+4*DIS,	pos_y);
	RenderPieceCastle(6,pos_x+2*DIS,	pos_y);

	RenderPieceCastle(2,pos_x,			pos_y-DIS);
	RenderPieceCastle(2,pos_x+DIS,		pos_y-DIS);
	RenderPieceCastle(2,pos_x+3*DIS,	pos_y-DIS);
	RenderPieceCastle(2,pos_x+4*DIS,	pos_y-DIS);
	RenderPieceCastle(4,pos_x+2*DIS,	pos_y-DIS);

	RenderPieceCastle(1,pos_x,			pos_y-2*DIS);
	RenderPieceCastle(7,pos_x+DIS,		pos_y-2*DIS);
	RenderPieceCastle(7,pos_x+2*DIS,	pos_y-2*DIS);
	RenderPieceCastle(7,pos_x+3*DIS,	pos_y-2*DIS);
	RenderPieceCastle(1,pos_x+4*DIS,	pos_y-2*DIS);

	RenderPieceCastle(3,pos_x+DIS,		pos_y-3*DIS);
	RenderPieceCastle(2,pos_x+2*DIS,	pos_y-3*DIS);
	RenderPieceCastle(5,pos_x+3*DIS,	pos_y-3*DIS);

	RenderPieceCastle(1,pos_x+DIS,		pos_y-4*DIS);
	RenderPieceCastle(1,pos_x+2*DIS,	pos_y-4*DIS);
	RenderPieceCastle(1,pos_x+3*DIS,	pos_y-4*DIS);

	SpriteHandlerSP->End();
}